<?php
namespace App\Models;

/**
 * 会员资金消费日志类
 */
class MConsumeLog extends BaseModel
{
    public $table = "consume_logs";

    public static $CONSUME_RECHARGE = 0;    //充值
    public static $CONSUME_DEDUCTING = 1;    //消费

    /**
     * 记录一条资金消费日志
     * $flag = 消费/充值
     * $wallet_type = 钱包类型
     */
    public static function log($uid, $username, $money, $flag, $wallet_type, $intro = "")
    {
        $log = new MConsumeLog();
        $log->no = onlyNo();
        $log->uid = $uid;
        $log->username = $username;
        $log->money = $money;
        $log->type = $flag;
        $log->wallet = $wallet_type;
        $log->intro = $intro;
        $log->time = time();

        return $log->save();
    }
}